home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu547.dms / pu547.adf / Spectrum.doc < prev    next >
Text File  |  1992-02-26  |  40KB  |  1,061 lines

  1.  
  2.  
  3.         Sinclair ZX Spectrum Emulator V2.0x     25 July 1994
  4.         -----------------------------------
  5.  
  6.  
  7. This program emulates a Sinclair ZX Spectrum 48-kbyte z80-based computer on
  8. any Amiga computer.
  9.  
  10.     
  11.  
  12. The files in this archive may be distributed anywhere provided they are
  13. unmodified and are not sold for profit.  Ownership remains with the author,
  14.  
  15.     Peter McGavin, 86 Totara Crescent, Lower Hutt, New Zealand.
  16.     e-mail: peterm@maths.grace.cri.nz    (note changed e-mail address).
  17.  
  18.  
  19. I assume you have enough knowledge to manipulate binary files and to transfer
  20. data over a serial line without help.  If you don't know what I'm talking
  21. about, don't try this program.
  22.  
  23.  
  24. Spectrum-00 is an executable for 68000-based Amigas only.
  25.  
  26. Spectrum-10 is for 68010-based Amigas, but also works on higher processors.
  27.  
  28. Spectrum-20 is optimised for 68020/30/40...-based Amigas with fast memory.
  29.  
  30. Spectrum-00-special is for 68000-based Amigas.  It is faster and dangerous.
  31.  
  32.  
  33. The Spectrum-00-special version takes some shortcuts to get some extra speed.
  34. Some games will run 2 or 3 times faster in Spectrum-00-special than in
  35. Spectrum-00, but because of the shortcuts, not all programs will work.  In
  36. the special version:
  37.  
  38.     o  Self-modifying z80 code does not work at all.  This affects some
  39.         games.  It also means that you will only be able to run one
  40.         program and then quit.  If you try to load a second Spectrum
  41.         program, without quitting Spectrum-00-special and re-running
  42.         it first, it very probably won't work.
  43.  
  44.     o  Code is optimised for faster animated graphics and scrolling, at
  45.         the expense of speed when the display is static, so you will
  46.         get faster animated games and slower ray-tracing  :-)
  47.  
  48.     o  The ROM is unprotected.  Note that the standard Spectrum ROM
  49.         corrupts itself.  In particular, location 0 usually gets
  50.         overwritten very quickly, so that NEW does not work any more.
  51.  
  52. Do not try to develop or write Spectrum programs with Spectrum-00-special,
  53. because you will probably lose your work.  It is provided only because it is
  54. significantly faster for running some animated Spectrum games.
  55.  
  56. All the programs require the file "spectrum.rom" (not supplied) in the current
  57. directory, or they will not load.
  58.  
  59. The emulator uses the dreaded move-sr instruction after almost every z80
  60. instruction emulated.  It ran 30-40% slower when I tried replacing the
  61. move-sr instruction with a call to GetCC()!  This is quite exceptional ---
  62. with most programs you wouldn't notice the difference.  Therefore I have
  63. supplied a 68010 version which uses move-ccr instead of move-sr.
  64.  
  65. The Spectrum-20 version uses 68020 addressing modes which are not available
  66. on lower processors.
  67.  
  68. The program has been tested on a 3.5 Mbyte Amiga 500 and on a 2 Mbyte Amiga
  69. 3000 (but it uses only about 300 kbytes).
  70.  
  71. I developed the code, entirely in assembler, in my spare time using z80
  72. emulation code based (originally) on Ulf Nordquist's CP/M emulator (Fred Fish
  73. disk 165).  I have fixed several bugs in the z80 emulation code, and made it
  74. more than twice as fast, but there are still some (very hard to find) bugs.
  75.  
  76.     
  77. Features:
  78. ---------
  79.  
  80. The following Spectrum features are implemented:
  81.  
  82.     screen output in the same resolution and colours as a real Spectrum
  83.         --- includes bright, reverse and flash attributes, and border
  84.         colour (looks much better than the old TV!)
  85.  
  86.     keyboard implemented at the z80 "in" instruction level.  Note that
  87.         like a real Spectrum you have to hold the key down until it
  88.         registers.  Because the emulator is running slower, you might
  89.         have to hold keys down longer.  More often, you might have to
  90.         hold your fingers off the keyboard for longer.  Make sure the
  91.         Spectrum window is active when you start to type.  See
  92.         Appendix 1 for key map.
  93.  
  94.     kempston joystick implemented at the Z80 "in" instruction level.  This
  95.         uses the rear Amiga gameport.  Note that the joystick is
  96.         active only when the Spectrum window is active.  If another
  97.         Amiga program is currently using the joystick, you will get a
  98.         retry/no-joystick requester.
  99.  
  100.     sound implemented using 2 techniques.  Calls to the "beeper" routine
  101.         at $03b5 in the Spectrum rom are trapped and the sound is
  102.         emulated at the exact same frequency and duration.  Sound is
  103.         also reproduced when a Spectrum program outputs to z80 port
  104.         254.  In this case the pitch and duration may or may not
  105.         sound correct, depending on the Spectrum program and the speed
  106.         of the Amiga you are using.
  107.  
  108.     cassette tape loading, if you have a sound sampler capable of at least
  109.         20 kHz sampling rate attached to your parallel port.  This is
  110.         implemented by trapping calls to the "ld-bytes" routine at
  111.         $056b in the Spectrum rom.  Note that copy-protected games
  112.         with custom loaders cannot always be loaded this way.
  113.  
  114. It is possible to save to and load from amiga disk files.
  115.  
  116.  
  117.  
  118. That Missing File:
  119. ------------------
  120.  
  121. As already mentioned, a vital file is missing.  You must supply an image of
  122. the Spectrum's ROM in the file "spectrum.rom".  The file must be exactly
  123. 16384 bytes long and must contain exactly the same byte sequence as memory
  124. locations 0..16383 in the Spectrum.  There are several ways to get this
  125. across to your Amiga, including:
  126.  
  127.     Use the Sinclair Interface 1 serial port connected to the Amiga's
  128.     serial port.  The data can be transferred using a small BASIC program
  129.     on the Spectrum, then captured on the Amiga with either another small
  130.     program or a comms program.
  131.  
  132.     Use a Spectrum disk drive system that writes IBM-format sectors, then
  133.     read the diskettes on your Amiga using MSH (Fred Fish disk 382) or
  134.     CrossDOS (commercial) and a sector editor like DiskX (Fred Fish disk
  135.     158).  An MGT PLUS D disk drive will work for this.
  136.  
  137.     Find a program that will read Spectrum cassette tapes through an Amiga
  138.     sound sampler, writing the data to a disk file as it goes.  Kristian
  139.     Nielson (e-mail bombadil@freja.diku.dk) has written a program that
  140.     will do this.  Try looking for specload.lzh at your local PD site.
  141.  
  142.     Find another Spectrum emulator that comes with the ROM code.  Rumour
  143.     has it that there is an Atari-ST Spectrum emulator comes with the ROM
  144.     code.
  145.  
  146. I'll leave it up to you to figure out how to get the data across.  You
  147. could always type it in :-)  There are several third-party books that list
  148. the code, e.g,
  149.  
  150.     "The Complete Spectrum ROM Disassembly" by Dr Ian Logan and Dr Frank
  151.     O'Hara, Melbourne House Software Ltd, ISBN 0 86161 116 0, or
  152.     ISBN 0 86759 117 X, 1983;
  153.  
  154.     "The Spectrum Machine Code Reference Guide" by Richard Ross-Langley,
  155.     Interface Publications, ISBN 0 907563 51 1, September 1983.
  156.  
  157. I believe that Spectrums have been sold with several slightly different ROMs,
  158. including Scandinavian and Argentinian internationalised versions.  Also
  159. various ROM patch hacks have been distributed around user-groups (requiring
  160. a personal ROM burner to apply).  Any ROM should work, but I have not been
  161. able to test them all.  A non-standard version should behave in the emulator
  162. exactly as if it was installed in a real Spectrum.
  163.  
  164. In fact you can supply any 16384-byte file containing valid z80 code and
  165. called spectrum.rom.  The emulator will transfer z80 control to location 0.
  166. Screen and keyboard hardware is programmed the same as a real Spectrum.
  167. (Once loaded, the first 16384 memory locations are readonly.)
  168.  
  169. Please don't ask me to e-mail spectrum.rom to you, because I won't.
  170.  
  171.  
  172.  
  173. Operation:
  174. ----------
  175.  
  176. You can start the emulator from either the Workbench or SHELL (or CLI).  There
  177. are no command-line parameters.
  178.  
  179. If you use the SHELL (or CLI), spectrum.rom must be in the current directory.
  180. From the workbench, spectrum.rom should be in the same directory as the
  181. program.
  182.  
  183. If the emulator can't find spectrum.rom, then it will display a requester
  184. saying so, and it will not run.
  185.  
  186. To use the ARP file requester, you must have arp.library installed in your
  187. LIBS: directory.
  188.  
  189. The emulator runs in its own custom screen and window.
  190.  
  191. The emulator does not disable multitasking, and it does not interfere with
  192. other tasks (except when loading from a sound sampler).  You can drag the
  193. screen down or click it to the back with the mouse, in the usual way.  (Grab
  194. the screen bar to the left of the window to pull it down.)
  195.  
  196. The emulator lowers its own priority to -5, otherwise it would significantly
  197. slow down other tasks.  Raising the priority back to 0 (e.g, with xoper or
  198. artm) does not significantly speed up the emulator on a standard system.
  199. Raising it higher will prevent most other tasks from running at all.
  200.  
  201. To exit the emulator, do any of the following:
  202.  
  203.     o  click the close box with the left mouse button;
  204.  
  205.     o  select "Quit..." from the Project menu, or
  206.  
  207.     o  press the ESC key.
  208.  
  209.  
  210.  
  211. Menus:
  212. ------
  213.  
  214. Project menu
  215.  
  216.     Reset...
  217.     Resets the z80, unless you cancel the requester that pops up.
  218.     This is like the Spectrum NEW command, but it works even when you
  219.     are running an "unbreakable" or "crashed" program.
  220.  
  221.     Load snapshot...  F1
  222.  
  223.     Loads a disk file that has been created with "Save snapshot",
  224.     restoring the state of the system to what it was when the snapshot
  225.     was made.  Any currently loaded Spectrum program is lost.  Uses
  226.     the ARP file requester.
  227.  
  228.     You can use "Load snapshot..." even if the Spectrum has "crashed",
  229.     or if you are running a Spectrum program which does not have a
  230.     "quit" option.
  231.  
  232.     Save snapshot...  F2
  233.  
  234.     Saves the current state of the emulator to a disk file.  The entire
  235.     state of the system is saved, including all 48 kbytes of Spectrum ram
  236.     and the state of the z80 processor.  Uses the ARP file requester.
  237.  
  238.     The format of a snapshot file is listed in Appendix 2.
  239.  
  240.     Help...         HELP
  241.  
  242.     Displays the "Spectrum.help" file, which is a diagram of a real
  243.     Spectrum keyboard.  You need about 70 kb of CHIP ram free for this.
  244.  
  245.     Quit...          ESC
  246.  
  247.     Quits the emulator.  (You get a chance to change your mind.)
  248.  
  249.  
  250. Settings menu
  251.  
  252.     LOAD/MERGE/VERIFY...
  253.  
  254.     Selects what happens when the emulator executes a Spectrum BASIC
  255.     LOAD, MERGE or VERIFY command.
  256.  
  257.     Note that this has nothing at all to do with "Load snapshot", which
  258.     always loads from disk.  What it does do, is to change the behaviour
  259.     of the standard Spectrum BASIC tape loading commands, which are
  260.     normally used to load, merge and verify BASIC programs, array data
  261.     and binary code, from cassette tape.
  262.  
  263.     In fact, this selects what happens when any program (including any
  264.     machine code program) calls the cassette tape loading routine in the
  265.     Spectrum rom.
  266.  
  267.     You have a choice of:
  268.  
  269.         Disk files
  270.  
  271.         Select a disk file using the ARP file requester.  The data
  272.         in the file is interpreted as if it is being read from cassette
  273.         tape.
  274.  
  275.         The first byte in the file is the "header" byte, then the raw
  276.         data, then the checksum byte.
  277.  
  278.         The Spectrum normally reads 2 blocks of data from cassette
  279.         tape, a "header" file followed by the "data" file.  These
  280.         should be stored in 2 separate disk files.  The emulator will
  281.         request both files.  I implemented it this way to allow support
  282.         for "headerless" files which are used by many Spectrum machine
  283.         code programs.
  284.  
  285.         Note that the Spectrum still thinks it is reading from cassette
  286.         tape, so you might see messages like "Start tape now", even
  287.         though it is reading from disk.
  288.  
  289.         If the file you select is not in the correct format, or if the
  290.         checksum is wrong, the Spectrum will usually just request the
  291.         same file again, without any messages, as if it read garbage
  292.         noise from cassette tape.
  293.  
  294.         ProSound
  295.  
  296.         Read data from a ProSound sound sampler connected to the
  297.         parallel port.
  298.  
  299.         Rombo
  300.  
  301.         Read data from a Rombo sound sampler connected to the parallel
  302.         port (the sampler that comes with MegaMIX Master software).
  303.         Please note that this option is untested.
  304.  
  305.         Other sampler
  306.  
  307.         Read data from any other kind of sound sampler connected to the
  308.         parallel port.
  309.  
  310.         The sampler must be capable of at least 20 kHz sampling rate
  311.         and it must be connected to the parallel port (not the game
  312.         port).
  313.  
  314.         You should be able to feed standard Spectrum cassette tapes in.
  315.  
  316.         Some copy-protected programs have custom loaders that will not
  317.         work in the emulator.
  318.  
  319.         It is possible to connect the Spectrum EAR output to the sound
  320.         sampler to transfer data directly from your Spectrum.  (Use a
  321.         SAVE command at one end, and a LOAD at the other.)
  322.  
  323.         Important: Interrupts on the amiga are disabled while you are
  324.         loading from a sound sampler.  This will interfere with other
  325.         tasks.  For example, a file transfer running in the background
  326.         will probably fail.  Please make certain that no other tasks
  327.         are writing to disk at the instant you start sampling!
  328.  
  329.  
  330.     You have a choice of:
  331.  
  332.         Disk files
  333.  
  334.         Select a disk file using the ARP file requester.  The data
  335.         that would normally be written to cassette tape is written
  336.         to the selected file instead.
  337.  
  338.         The first byte in the file is the "header" byte, then the raw
  339.         data, then a checksum byte.
  340.  
  341.         The Spectrum normally writes 2 blocks of data to cassette
  342.         tape, a "header" file followed by the "data" file.  These
  343.         should be stored in 2 separate disk files.  The emulator will
  344.         request both files.  I implemented it this way to allow support
  345.         for "headerless" files which are used by many Spectrum machine
  346.         code programs.
  347.  
  348.         Note that the Spectrum still thinks it is writing to cassette
  349.         tape, so you might see messages like "Start tape, then press
  350.         any key".
  351.  
  352.         Audio
  353.  
  354.         Not implemented in V2.0.
  355.  
  356.  
  357.  
  358. More on Reading Cassette Tapes:
  359. -------------------------------
  360.  
  361. To load a cassette tape through your sound sampler, first select your sampler
  362. type in the Settings menu, then enter LOAD "" (that is, J followed by ALT/P
  363. twice, then RETURN).  Now start the cassette tape playing into your sound
  364. sampler.  If it is working, the screen border should flash colours, very much
  365. like your Spectrum, and the mouse pointer will be frozen.
  366.  
  367. The MERGE and VERIFY commands should also work, as should things like
  368. LOAD "" CODE, etc.
  369.  
  370. The border of the screen flashes different colours, exactly like a real
  371. Spectrum.  The colours mean:
  372.  
  373.     flashing yellow and blue:    the load is working
  374.     flashing red and white:        synchronising or not working
  375.     not flashing:            not working or tape not playing
  376.  
  377. If it doesn't work, try adjusting the volume and tone controls on the tape
  378. recorder.  If you have trouble, try adjusting the controls while sampling
  379. with software that came with your sampler.  Ideally, the input should be a
  380. square wave which fills the graphic display.  I found it necessary to have
  381. the volume control much lower than when using a real Spectrum, but it
  382. probably varies, depending on the sampler type.
  383.  
  384. You should be able to save directly from your Spectrum to the Amiga with a
  385. direct connection --- i.e, no cassette tape or recorder at all.  Use a SAVE
  386. command on the Spectrum and a corresponding LOAD command in the emulator.
  387.  
  388. Loading works by intercepting calls to the LD-BYTES routine at location
  389. $056b in the Spectrum ROM.  If a Spectrum program has its own loading
  390. routine, then it won't work.  Some copy-protected games and fast-loaders
  391. are like that, and they will not work.  On the other hand, some Spectrum
  392. programs call LD-BYTES to load headerless tape files.  Those programs
  393. should work fine.
  394.  
  395. If you have been using the parallel port recently (for printing or ParNet
  396. for example), you might get a requester asking you to please free up the
  397. parallel port.  Try shutting down the program that has allocated it.
  398.  
  399. The following sound samplers should be suitable, but I have not had the
  400. opportunity to test any except the first:
  401.  
  402.     o ProSound
  403.  
  404.     o Rombo (the one that comes with MegaMIX Master)
  405.  
  406.     o Perfect Sound (except that recent Perfect Sound samplers are
  407.         different from early versions and recent ones might not work)
  408.  
  409.     o Datel DSS
  410.  
  411.     o Future Sound
  412.  
  413. Documentation on how various samplers work seems to be hard to obtain.
  414. They all seem to be slightly different, especially the way stereo/mono
  415. modes are switched and different channels are selected.
  416.  
  417. For the technically minded, here are the cia register settings currently
  418. used by the loader:
  419.                 ProSound    Rombo        Other
  420.     setup ciab-ddra        4        7        6
  421.     setup ciab-pra        4,0 or none *    6        4
  422.     inter-sample ciab-pra    4,0,4,0        none        none
  423.     ciaa-prb input bias    $80        $80        $80
  424.  
  425.     * If bit 0 of ciab-pra is 0 then output 4 followed by 0 else none.
  426.  
  427. Note that the tape-loading routine disables interrupts for the whole time
  428. it takes to load a tape.  That greatly exceeds Commodore's recommended
  429. limit of 250 microseconds.  While interrupts are disabled, the mouse
  430. pointer freezes, the keyboard is locked out, all other tasks stop, and any
  431. data arriving at the serial port is lost.
  432.  
  433. Please make sure your disks are not busy when you start to load a tape.
  434. Especially make certain that no other program is writing to your hard disk!
  435.  
  436. If I knew another way to make it work, I'd do it that way.  As far as I am
  437. aware, all sound sampling software on the Amiga disables interrupts for
  438. excessive periods.  The Spectrum loader has to interpret the incoming data
  439. in real time, which is quite a lot more than just saving it to a buffer in
  440. memory.
  441.  
  442. To break out of the load routine without actually loading anything, press
  443. the left mouse button.  The Spectrum BREAK key (SHIFT/SPACE) won't work in
  444. this situation.
  445.  
  446. If the keyboard doesn't work after you break out with the left mouse
  447. button, it's probably because you accidently deselected the window (by
  448. clicking outside it).  Just click anywhere inside the Spectrum window
  449. and the keyboard will work again.
  450.  
  451. The load routine is based on code kindly provided by Kristian Nielson.
  452. It has been tested on both standard and accelerated amigas.
  453.  
  454.  
  455. General Notes:
  456. --------------
  457.  
  458. o   The emulator runs about 2 to 8 times slower than a real Spectrum, on a
  459.     standard 68000-based A500.  If you are the lucky owner of an Amiga 3000,
  460.     the emulator runs faster than a real Spectrum, but make certain it's
  461.     running out of FAST ram.  If you run it out of CHIP ram, then it's more
  462.     than twice as slow.  I'm afraid the 68000 doesn't have a built-in z80
  463.     emulation mode, and a 3.5 MHz z80 is much harder to emulate than a 6502
  464.     as used in the Commodore 64 and BBC microcomputers.  The Spectrum NEW
  465.     command takes 9.7 seconds on an A500, compared with about 2.0 seconds on
  466.     a real Spectrum, 1.8 seconds on an A3000 (in FAST static-column ram), and
  467.     1.6 seconds on a 33MHz Mega-Midget-Racer with 32-bit ram.  One person
  468.     reported to me that it runs about 3 times faster again on a 68040.
  469.  
  470.  
  471. o   This version of Spectrum uses the blitter to refresh the screen in
  472.     parallel with the emulator.  That is, it uses multi-processing.  Thus,
  473.     the overhead of a z80 instruction writing to the Spectrum's display file
  474.     is minimised.  Before you A3000 owners complain that the 68030 is faster
  475.     than the blitter for blitting, remember that while the blitter is
  476.     refreshing the screen, the 68030 is busy emulating the z80.  The program
  477.     uses QBlit() for concurrency, not OwnBlitter() which would block the z80
  478.     emulator.
  479.  
  480.  
  481. o   I've just about run out of ideas on how to significantly speed up the
  482.     code from what it is now.  One thought is to code some common ROM routines
  483.     in pure 68000.  Obvious candidates are the text output, scrolling, and
  484.     maskable interrupt routines.  Of course this would only speed up programs
  485.     that call the ROM, which excludes most games.  Also, It would probably be
  486.     illegal.  The major speed bottleneck used to be the z80 instruction
  487.     decode.  I've pretty well eliminated that by going to threaded code.  The
  488.     display routines are about as fast as I can get them.  Taking over the
  489.     machine and doing everything at the hardware level would probably give
  490.     only a slight speed improvement, and the program would become much less
  491.     friendly and less portable.
  492.  
  493.  
  494. o   In version 2.0, the following Spectrum features are NOT implemented yet:
  495.  
  496.     saving to cassette tape;
  497.  
  498.     bank roms (e.g, Interface 1);
  499.  
  500.     printing to a printer
  501.  
  502.  
  503. o   The following z80 features are NOT properly implemented:
  504.  
  505.     the z80 h processor flag;
  506.  
  507.     the z80 daa instruction (decimal adjust a) --- daa works properly only
  508.         immediately after add, sub, adc or sbc;
  509.  
  510.     the timer interrupt occurs after every 1500 branch, jump, call and
  511.         return z80 machine instructions, instead of every 20 ms.  On
  512.         accelerated amigas, interrupts will not occur any faster than
  513.         every 20 ms.
  514.  
  515.     updating of the flash attribute occurs every 24000 branch, jump, call
  516.         and return z80 instructions, instead of every 320 ms.  On
  517.         accelerated amigas, the flash speed will never be faster than
  518.         every 320 ms.
  519.  
  520.     interrupts and screen updates can occur only immediately after branch,
  521.         jump, call, return and halt z80 machine instructions.
  522.  
  523.     because the emulator is not real-time, the real interval between timer
  524.         interrupts and flash attribute updates depends on the nature
  525.         of the Spectrum program being run.
  526.  
  527.     there might still be rare problems executing certain long,
  528.     self-modifying z80 instructions located at exactly 32763..32766 in z80
  529.     memory, because of the 68000 addressing modes used to load instruction
  530.     operands;
  531.  
  532.     there is at least one other bug I haven't been able to track down yet.
  533.  
  534.  
  535. o   The emulator allocates and uses two sound channels.  If there are not
  536.     enough free channels, you get the option of running the emulator with no
  537.     sound.  If you have enough memory you can test this by running 3 copies of
  538.     Spectrum at once!
  539.  
  540.  
  541. o   Because it's running slower, maybe now you can get past that "impossible"
  542.     level in your favourite game.
  543.  
  544.  
  545. o   Now you can print Spectrum graphics by transferring to your Amiga.
  546.  
  547.  
  548. o   If you're cross-developing Spectrum software, now you can see which parts
  549.     need speeding up.
  550.  
  551.  
  552. o   I've tested it with several Sinclair Basic programs and all ran perfectly.
  553.  
  554.  
  555. o   I've tried lots machine-code programs and most work ok.  The following
  556.     programs seem to work ok in the emulator:
  557.  
  558.         Zeus Assembler and Monitor
  559.         Scrabble
  560.         Jetset Willy
  561.         Atic Atac
  562.         Jetpac
  563.         Tron
  564.         The Train Game
  565.         Backgammon
  566.         PSSST
  567.         Horace and the Spiders
  568.         Sam Spade
  569.         Draughts
  570.         Sam Stoat
  571.         3D Deathchase
  572.         Technician Ted
  573.         Kosmic Kanga
  574.         Monty Mole
  575.         Talk Chess
  576.         Horace Goes Skiing
  577.         Hungry Horace
  578.         Star Raid
  579.         Cyclone
  580.         Wheelie
  581.         Full Throttle
  582.         Mugsy
  583.         Dynamite Dan
  584.         Dynamite Dan II
  585.         Heathrow
  586.         IS Chess 48
  587.         Matchpoint
  588.         Max Headroom            no joystick
  589.         Spy vs Spy
  590.         Kong
  591.         The Alchemist
  592.         Daley Decathlon
  593.         Automania
  594.         Penetrator
  595.         Gyron
  596.         Alien8
  597.         Cyberun
  598.         KnightLore
  599.         Batman
  600.         Tomahawk
  601.         Fighter Pilot
  602.         Athena
  603.         Basil the Detective
  604.         Pacland
  605.         Orbix
  606.         Meteor
  607.         Manic Miner
  608.         Madmix
  609.         Kokotoni Wilf
  610.         Ikari Warriers
  611.         Gauntlet
  612.         Dustin
  613.         Ant Attack
  614.  
  615.  
  616.     St Bernard resets the Spectrum at the end of the first level.
  617.  
  618.     SabreWulf runs, except sometimes the rhino runs backwards (very
  619.     amusing).
  620.  
  621.     (If you know why either of these programs don't work, please tell me.)
  622.  
  623.     Note: The Amiga doesn't crash.  If a Spectrum program crashes, you can
  624.     either:  Quit the emulator and continue working on the Amiga, or:
  625.     Press F1 and load another snapshot.
  626.  
  627.     Note: Some of the above have not been tested since Spectrum v0.7 or v0.8.
  628.  
  629.     Another note: Some of the above programs won't load from tape, but they
  630.     will run if you can create a snapshot file somehow (e.g, Mirage Microdriver
  631.     and serial port).
  632.  
  633.  
  634. o   One problem I have had with snapshotting games by transferring a snapshot
  635.     file from the real Spectrum to the amiga, is as follows:  If there is
  636.     non-standard hardware in your real Spectrum (like a non-standard joystick or
  637.     disk drive), and the program knows about the special hardware, then the
  638.     program might have already done a hardware test (before you made the
  639.     snapshot) that makes it believe the special hardware exists permanently.
  640.     Then, when run under the emulator, the program tries to access the
  641.     non-existent hardware and behaves erratically.
  642.  
  643.     What is wrong is that the program was started in one environment (the real
  644.     Spectrum with add-ons) and is now running in another (the plain Spectrum
  645.     emulator).  For example, if your program behaves as if the joystick button
  646.     is continuously pressed (when run in the emulator), maybe it is because
  647.     you made the original snapshot from a Spectrum which has non-standard
  648.     joystick hardware.  See if you can disconnect the joystick interface and
  649.     reload the original program from tape before you make a snapshot.
  650.  
  651.  
  652. o   If the keyboard, joystick and/or menus do not respond at all, well,
  653.     then...  er...  umm... --- try clicking in the window  :-)
  654.  
  655.  
  656. o   I am not supplying the source of the emulator yet.
  657.  
  658.  
  659. o   Please report bugs to peterm@maths.grace.cri.nz.  I'd much prefer bug
  660.     reports like "the `or' instruction doesn't zero the carry flag" to
  661.     "Dan Dare doesn't work".
  662.  
  663.  
  664.  
  665. Appendix 1:  The keyboard:
  666.  
  667. The Spectrum has a weird way of mapping functions to keys that doesn't
  668. translate nicely to the Amiga.  To get a "[" on a real Spectrum, for example,
  669. you press CAPS-SHIFT and SYMBOL-SHIFT together followed by SYMBOL-SHIFT and F.
  670. In the emulator, you do the same thing except CAPS-SHIFT is either of the
  671. SHIFT keys and SYMBOL-SHIFT is either of the ALT keys.  Pressing "[" on the
  672. Amiga keyboard won't work.
  673.  
  674. The following table lists the Amiga key(s) corresponding to each Spectrum key:
  675.  
  676.     Amiga key        Spectrum key
  677.  
  678.     0..9            0..9
  679.     keypad 0..9        0..9
  680.     A..Z            A..Z
  681.     SPACE            SPACE
  682.     RETURN or ENTER        ENTER
  683.     either SHIFT key    CAPS-SHIFT
  684.     either ALT key        SYMBOL-SHIFT
  685.  
  686. The following special Amiga keys correspond to Spectrum key combinations.
  687.  
  688.     Amiga key        Spectrum key combination
  689.  
  690.     .            SYMBOL-SHIFT/M
  691.     ,            SYMBOL-SHIFT/N
  692.     ;            SYMBOL-SHIFT/O
  693.     -            SYMBOL-SHIFT/J
  694.     =            SYMBOL-SHIFT/L
  695.     keypad (        SYMBOL-SHIFT/8
  696.     keypad )        SYMBOL-SHIFT/9
  697.     keypad /        SYMBOL-SHIFT/V
  698.     keypad *        SYMBOL-SHIFT/B
  699.     keypad -        SYMBOL-SHIFT/J
  700.     keypad +        SYMBOL-SHIFT/K
  701.     keypad ENTER        ENTER
  702.     keypad .        SYMBOL-SHIFT/M
  703.     left arrow        SHIFT/5
  704.     down arrow        SHIFT/6
  705.     up arrow        SHIFT/7
  706.     right arrow        SHIFT/8
  707.  
  708. ESC quits the emulator (unless you cancel the requester that comes up).
  709.  
  710. HELP displays the Spectrum.help file, which is a diagram of the real Spectrum
  711. keyboard.  (You need about 70 kb of CHIP ram free for this.)
  712.  
  713. F1 brings up the load snapshot requester (provided arp.library is installed).
  714.  
  715. F2 brings up the save snapshot requester (provided arp.library is installed).
  716.  
  717. F3 changes the sampler type for cassette tape loading.
  718.  
  719. All the other Amiga keys do nothing.
  720.  
  721.  
  722.  
  723. Appendix 2:  Snapshot file format:
  724.  
  725. This format is based on the format used by the Mirage Microdriver "Dump"
  726. command.  Snapshot files are always 49179 bytes long.  Note that in the table,
  727. the byte offset starts from 0, not 1.
  728.  
  729.     Byte offset into file        Value
  730.  
  731.     0                i  register
  732.     1                l' register
  733.     2                h' register
  734.     3                e' register
  735.     4                d' register
  736.     5                c' register
  737.     6                b' register
  738.     7                f' register
  739.     8                a' register
  740.     9                l  register
  741.     10                h  register
  742.     11                e  register
  743.     12                d  register
  744.     13                c  register
  745.     14                b  register
  746.     15                iy low register
  747.     16                iy high register
  748.     17                ix low register
  749.     18                ix high register
  750.     19                bit 2 is set if interrupts are enabled
  751.     20                r register
  752.     21                flags register
  753.     22                a register
  754.     23                sp low register
  755.     24                sp high register
  756.     25                interrupt mode (0, 1 or 2)
  757.     26                border colour in low 3 bits
  758.     27..49178            48 kbytes ram dump
  759.  
  760.  
  761.  
  762. Appendix 3:  Other Spectrum Emulators:
  763.  
  764.  
  765. When I started this project I did not know of any other Spectrum emulators.
  766. Now I have heard of at least 12, including this one, in various stages of
  767. development.
  768.  
  769. 1: This one.
  770.  
  771. 2: The public domain K.G.B. emulator advertised in "Amiga Format".  I have
  772. seen only version 1.2 which does not multitask and does not work properly on
  773. my A3000.
  774.  
  775. 3: An Italian emulator was released (possibly commercially) about 3 years ago.
  776. The version I saw was very bug free and worked on accelerated amigas, but it
  777. did not multitask and was slightly slower than mine.
  778.  
  779. 4: An emulator is under development in Sweden.
  780.  
  781. 5: Another emulator, intended to be commercial, was written in Holland, but it
  782. was never released as far as I know.  From what I have heard about it, it is
  783. much faster than mine.
  784.  
  785. 6: The Whitby Software Spectrum Simulator is a Spectrum ROM rewrite for the
  786. C64.  It runs just fine under TheA64Package and is surprisingly fast.  Because
  787. it is a ROM rewrite and not a z80 emulator, you cannot run z80 machine code
  788. programs (i.e, most games).
  789.  
  790. 7: VGASPEC is a Spectrum emulator for the IBM-PC and clones (not for the
  791. amiga).  A VGA graphics adaptor is required.  I think it was developed in
  792. Spain or Portugal (I don't recognise the language that all the messages are
  793. written in).
  794.  
  795. 8: JPP is another Spectrum emulator for the IBM-PC and clones, developed
  796. recently by Arnt Gulbrandsen.  An 80386 and VGA are required.  It is faster
  797. than VGASPEC.  The name JPP is derived from the keys you press to get LOAD "".
  798.  
  799. 9: There is another very good Spectrum emulator for the IBM-PC.  From memory
  800. I think it is called Z80.
  801.  
  802. 10: There is a Spectrum emulator for the Atari ST available from various ftp
  803. sites.
  804.  
  805. 11: I heard from one person working on a Spectrum emulator for the BBC RISC
  806. computer (status unknown).
  807.  
  808. 12: I have heard rumours of other emulators in various stages of development
  809. in Australia and Germany for platforms including the Amiga, the IBM-PC and
  810. Unix/X-Windows.
  811.  
  812. There is a good collection of Spectrum emulators available by ftp from
  813. wuarchive.wustl.edu and its mirrors.  Programs to convert between various
  814. snapshot formats are also available there.
  815.  
  816.  
  817. Appendix 4:   Update Notes:
  818.  
  819.  
  820. v0.0    22 Oct 1990
  821.  
  822. First release.
  823.  
  824.  
  825. v0.1    15 Nov 1990
  826.  
  827. Sped up display code slightly.  Also sped up main instruction decode slightly.
  828. Display flash attribute as reverse.
  829.  
  830.  
  831. v0.2    30 Dec 1990
  832.  
  833. Now use double buffered display and implemented flash attribute properly.
  834. Added error requesters.
  835. Used pc-relative jump tables in z80 emulator --- slightly faster, and much,
  836. much smaller.
  837.  
  838.  
  839. v0.3    20 Jan 1991
  840.  
  841. Changed display routines to update screen periodically instead of after every
  842. z80 instruction that pokes the Spectrum's display file.  Used the blitter for
  843. this, running in parallel with the z80 emulator.  (Only character rows that
  844. have changed since the last screen update are redrawn.)
  845. Reverted to single buffer display and used blitter to implement flash.  (It's
  846. smaller and faster this way.)
  847. Fixed bug where couldn't use path string in arp file requester.
  848.  
  849.  
  850. v0.4
  851.  
  852. Changed the z80 emulator to use threaded code.  Now all that is executed between
  853. each pair of z80 instructions is "move.w (a3)+,d6; jmp table(pc,d6.w)" instead
  854. of about ten 68000 instructions to decode the next z80 opcode byte.  Overheads
  855. introduced are a new 128 kbyte table giving the routine offset for every byte
  856. in z80 ram, and the necessity to write a zero word into this table every time
  857. the emulator writes to z80 ram.  The overall speed increase is about 20%.
  858. Expanded some subroutines to macros and expanded $dd and $fd prefix
  859. instructions to independent code for a slight speed increase.  A side-effect
  860. is that the executable increased in size from 27k to over 40k.
  861. Introduced some bugs during the systematic changes that are proving hard to
  862. track down.
  863.  
  864.  
  865. v0.5     7 Apr 1991
  866.  
  867. Fixed bug in "sra a" instruction.
  868. Fixed bugs in rotate and shift (ix+d) and (iy+d) instructions.
  869. Fixed bugs where used "offset(a4,rr.w)" to address z80 memory space where offset
  870. is -2, -1, 1 or 2.  (Can't use that mode because of the unlikely event of rr.w
  871. being near $8000.)
  872. Implemented mode 2 interrupts.  Low byte of interrupt vector (normally
  873. provided by an external peripheral device) is assumed to be 0.
  874. Increased the interrupt interval from 2500 instructions to every 5000
  875. instructions, because otherwise some programs with their own (mode 2)
  876. interrupt routines overflowed the stack.
  877.  
  878.  
  879. v0.6    23 Apr 1991
  880.  
  881. Fixed bugs in the following z80 instructions:
  882.     ld     ixh,b
  883.     ld    ixh,d
  884.     rl    (ix+dd)
  885.     rr    (ix+dd)
  886.     sla    (ix+dd)
  887.     cpdr
  888. and iy equivalents of the above instructions.
  889. Implemented ini, outi, ind, outd, inir, otir, indr, otdr.  (Out instructions do
  890.     nothing).
  891. Now preserve (otherwise) unused flag bits in push af, pop af and ex af,af'
  892.     (instead of setting them all to 0).
  893. Changed layout of vector table for threaded code (origin now in middle).
  894. Fixed bug in vector table wraparound code (when pc incremented from 32767 to
  895.     32768).
  896. Sped up ram writes by optimising macro for writing a byte to ram.
  897. Added processor type check.  Now you get a requester when you try to run the
  898.     wrong version for your processor type, instead of "Software Error,
  899.     Task Held".
  900. Implemented sound by opening audio.device and trapping calls to the "beeper"
  901. subroutine at $03b5 in Spectrum ROM.
  902.  
  903.  
  904. v0.7
  905.  
  906. Optimised blits to update flash attributes by keeping track of which parts of
  907. the display are flashing and updating only those parts.  That saves a lot of
  908. blits.  No blits are needed at all when there are no flashing characters
  909. displayed.  It used to redraw the entire display for every blink.
  910.  
  911.  
  912. v0.8    13 May 1991
  913.  
  914. Further optimised the display routines by adding a 6144-byte lookup table.
  915.  
  916.  
  917. v0.9    22 Jul 1991
  918.  
  919. Lower task priority to -5 at startup.  This is friendlier to other tasks
  920. because Spectrum is highly CPU intensive.  If Spectrum is running at a higher
  921. priority than another task, then that other task is completely blocked.
  922. Sped up the emulator by 5% by checking for interrupts only after branch, jump,
  923. call and return instructions, instead of after all instructions.
  924. Open gameport.device and emulate Kempston joystick (at Z80 "in" instruction
  925. level) using the rear Amiga gameport.
  926.  
  927.  
  928. v0.9b    1 Sep 1991
  929.  
  930. Implemented all the undocumented z80 sls instructions.
  931. Fixed bug in ld (nn),sp instruction.  (It didn't work at all!)
  932. Implemented the z80 n flag --- all instructions now set/reset the n flag.
  933. Fixed bugs in inc/dec (hl), inc/dec (ix+dd) & inc/dec (iy+dd) (never set v).
  934. The daa instruction now works correctly after add and sub (not just adc & sbc).
  935. Incorporated Kristian Nielson's tape load routine.
  936. Allocate/free misc.resource.
  937. Added "File already exists! Overwrite?" requester (in save snapshot).
  938. Fixed keypad 0 key.
  939. Rationalised keyboard.  Arrow keys are now equivalent to SHIFT+5/6/7/8 instead
  940. of 5/6/7/8 (without the SHIFT).
  941. ESC key quits.
  942. The halt instruction now calls WaitTOF().  (Was too fast.)  The Spectrum Basic
  943. PAUSE function now works correctly.
  944. Added a separate timer task to prevent interrupts occurring too quickly.  The
  945. "flash" rate and keyboard interrupt rates are now more constant.
  946. The HELP key now displays Spectrum.help IFF/ILBM file from current directory.
  947. Reorganised register usage in z80 emulator to try to speed it up (lots of work
  948. but not much success).
  949.  
  950.  
  951. v1.0    9 Nov 1991
  952.  
  953. Implemented menus.
  954. Added noise correction code to cassette tape loader.
  955. Added support for 2 kinds of sound samplers.
  956. Screen to front after error requester in IFF loader.
  957. Use an interrupt server instead of extra task for timer.
  958. Further optimised blitter routines.
  959. Put z80 parity byte in a register (slight speedup).
  960. Implemented ld-bytes and sa-bytes to/from disk.
  961.  
  962.  
  963. v1.1    Dec 1991
  964.  
  965. Created 68020 version (uses 68020/30/40-only addressing modes for extra speed)
  966. Moved z80 address space to FAST RAM with a copy of 16384..22527 in CHIP RAM
  967. (instead of having the whole Z80 address space in CHIP RAM).
  968. Added more undocumented z80 instructions.
  969. Sped up display routines by changing update algorithm.  Animated graphics and
  970. scrolling are now faster by a factor of 2 or 3.
  971.  
  972.  
  973. v1.2    7 Jan 1992
  974.  
  975. Rewrote joystick handling routines to avoid continuous polling.
  976.  
  977.  
  978. v1.3    Feb 1992
  979.  
  980. Implemented a much faster algorithm for handling z80 prefix instructions that
  981. was suggested to me by Richard Carlsson.
  982. Preserve high bit of R register between LD R,A and LD A,R, and also in snapshot
  983. files.  Tomahawk works now.
  984. GetCC() is now documented to preserve d0/d1/a0/a1.  Fixed movesr macro.
  985. Mode 2 interrupts assume $ff is on the external bus, not $00.  This change
  986. fixed quite a few games.
  987. Fixed glaring bug in "set 4,l" instruction.  Sabre Wulf, Fighter Pilot, Basil
  988. the Detective, Athena and lots of other programs work now.
  989. Changed implementation of daa instruction to speed up add/adc/sub/sbc instrs.
  990. Use blitter to do comparisons as well as copies in display updater.
  991. Sped up CPU computation of blitter attribute masks in display updater.
  992. Display updater now translates black to bright black on the fly.  This leaves a
  993. colour register free for the border colour (one day).
  994. Fixed bug in display updater that caused flashing to fail sometimes.
  995.  
  996.  
  997. v1.4    17 Mar 1992
  998.  
  999. Changed ld-bytes ROM patch entry point from $0556 to $056b to be compatible
  1000. with more programs.
  1001.  
  1002.  
  1003. v1.4a    22 Mar 1992
  1004.  
  1005. Sped up LDIR by calling CopyMem().  This nearly doubled the speed of some
  1006. programs (e.g, ManicMiner and JetsetWilly).
  1007. Increased the interrupt rate and screen refresh rate when executing lots of
  1008. large LDIRs.
  1009.  
  1010.  
  1011. v1.5    27 Dec 1992 (This version later abandoned)
  1012.  
  1013. Major revamp of z80 emulator, as suggested by several correspondents (3 days'
  1014. work).
  1015. Implemented conventional decoding scheme for z80 instructions, and did away
  1016. with threaded code tables and the overhead of updating them on every write.
  1017. 68000 and 68010 versions now use 2-instruction decode (self-modifying) as
  1018. follows:
  1019.     move.b    (a3)+,1$+2-base(a5)    ; get opcode and modify next instr
  1020. 1$:    jmp    $ff00(a5)        ; jump directly to next instruction
  1021. 68020/30/40 version uses a slightly longer macro to avoid self-modifying code.
  1022. Instruction routines are all exactly 256 bytes in size and the total size of
  1023. all 256 routines is 64 kbytes.
  1024. Added about 5 more such 64 kb blocks of code for prefixed instructions.
  1025. Managed to interleave all the 64 kb code blocks so that they effectively
  1026. reduced to a single 64 kb code block (even sharing the same base address
  1027. register but each table having a different byte-offset).
  1028. About 25 instruction routines didn't fit in their allocated space and
  1029. required long jumps to routines elsewhere.
  1030. Several features broke, including ROM write-protection, invisible ROM-hooks
  1031. for load/save/beep, (in fact I did not re-implement ROM hooks, so loading,
  1032. saving and sound did not work at all), daa mechanism, fast prefix mechanism,
  1033. potential to treat common sequences of instructions as a single instruction
  1034. with no overhead, etc.
  1035. Speed was almost exactly the same as v1.4a (which still had the broken features
  1036. intact), and there seemed to be no significant advantages.
  1037.  
  1038.  
  1039. v1.6    25 Jan 1993
  1040.  
  1041. Gave up on conventional decoding and reverted to v1.4a sources.
  1042. Implemented border colour (at last!)  Made window borderless and changed
  1043. colours.
  1044. The old "filler" byte in the snapshot file format now holds the border colour.
  1045. Added "Reset" menu item.
  1046. Changed sa-bytes ROM patch entry point from $04c2 to $04c6 to be compatible
  1047. with more programs.
  1048. The ld-bytes and sa-bytes routines were not always setting the de, ix and flag
  1049. registers on return, causing some tape-copying programs to fail.  Corrected
  1050. the problem.
  1051. File-names longer than 10 characters passed to the SAVE command could crash
  1052. the amiga.  Corrected the problem.
  1053. Added support for Rombo sound sampler (the one that comes with MegaMIX
  1054. Master).  I do not own a Rombo sound sampler and I have been unable to test
  1055. this option.  (I used information provided by a correspondent in Portugal,
  1056. who also informed me that v1.4a did not work with his Rombo sampler.)
  1057. Implemented sound at the z80 port 254, bit 4, level.
  1058. Changed keyboard handling code to precalculate the most common z80 port address
  1059. values whenever a key is pressed or released, instead of doing a full
  1060. calculation every time an "in" instruction is executed.
  1061.